package org.iabako.server.serviceimpl.report;

import org.apache.log4j.Logger;
import org.iabako.server.dao.report.ExpenseReportDAO;
import org.iabako.shared.dto.FinancesBalance;
import org.iabako.shared.dto.ReportGenerationInputDTO;
import org.iabako.shared.iservice.report.ExpenseReportGeneratorService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.Map;

/**
 * Created by jose on 28/01/15.
 */

@org.springframework.stereotype.Service("expenseReportGeneratorService")
public class ExpenseReportGeneratorServiceImpl extends AbstractReportService implements ExpenseReportGeneratorService {

    static Logger log = Logger.getLogger(InstallmentReportGeneratorServiceImpl.class.getName());

    @Autowired
    ExpenseReportDAO expenseReportDAO;

    @Override
    protected String getReportFileName() {
        return messages.getLabel("report_expenses_filename");
    }

    @Override
    protected String getReportTitle() {
        return "";
    }

    @Override
    protected String getColumnStyleLabel1() {
        return messages.getLabel("report_expenses_to_pay_view");
    }

    @Override
    protected String getColumnStyleLabel2() {
        return messages.getLabel("report_expenses_payed_view");
    }

    public String generateExpenseReport(ReportGenerationInputDTO reportGenerationInputDTO) {
        return generateReport(reportGenerationInputDTO);
    }

    @Override
    protected Map<Object, FinancesBalance> getDataMapByEntity(ReportGenerationInputDTO reportGenerationInputDTO, Date dateAfter, Date dateBefore) {
        return expenseReportDAO.getExpenses(dateAfter, dateBefore);
    }

    @Override
    protected Double getColumnValue1(FinancesBalance financesBalance) {
        return financesBalance.getExpensesPayable();
    }

    @Override
    protected Double getColumnValue2(FinancesBalance financesBalance) {
        return financesBalance.getExpensesPayed();
    }
}
